//导入vue-router
import { createRouter, createWebHistory, routerKey } from "vue-router";

//导入组件
import LoginVue from "@/views/login.vue";
import LayoutVue from "@/views/Layout.vue";
import HomeworkManageVue from "@/views/homework/HomeworkManage.vue";
import QuestionTypeVue from "@/views/questions/QuestionType.vue";
import QuestionManageVue from "@/views/questions/QuestionManage.vue";
import UserAvatarVue from "@/views/user/UserAvatar.vue";
import UserInfoVue from "@/views/user/UserInfo.vue";
import UserRestPasswordVue from "@/views/user/UserResetPassword.vue";
import CourseTypeVue from "@/views/courses/CourseType.vue";
import CourseManageVue from "@/views/courses/CourseManage.vue";
import UserManageVue from "@/views/user/UserManage.vue";
import PurchaseManageVue  from "@/views/purchase/PurchaseManage.vue";
import ExamManageVue from "@/views/exam/ExamManage.vue";
import UserEMGradeManageVue from "@/views/exam/UserEMGradeManage.vue"
import UserHKGradeManageVue from "@/views/homework/UserHKGradeManage.vue"
import LogInfoManageVue from "@/views/Setting/LogInfoManage.vue"
import NoticeManageVue from "@/views/Setting/NoticeManage.vue"
import HomePageVue from "@/views/Homepage/HomePage.vue"
import CommentManageVue from "@/views/courses/CommentManage.vue"
import CourseCMTManageVue from "@/views/courses/CourseCMTManage.vue"
import CozeVue from "@/views/Coze/Coze.vue"

//定义路由关系
//也就是路径和组件的对应关系
const routes = [
  { path: "/login", component: LoginVue },
  {
    path: "/",
    name: "主页",
    component: LayoutVue,
    redirect: "/homepage",//重定向
    children: [
      {
        path: "/questions/type",
        name: "QuestionType",
        component: QuestionTypeVue,
        meta: { title: "题目管理>题目类型" }
      },
      {
        path: "/questions/manage",
        name: "QuestionManage",
        component: QuestionManageVue,
        meta: { title: "题目管理>题目库" }
      },
      {
        path: "/user/avatar",
        name: "UserAvatar",
        component: UserAvatarVue,
        meta: { title: "个人中心>用户头像" }
      },
      {
        path: "/user/info",
        name: "UserInfo",
        component: UserInfoVue,
        meta: { title: "个人中心>用户信息" }
      },
      {
        path: "/user/resetPassword",
        name: "UserResetPassword",
        component: UserRestPasswordVue,
        meta: { title: "个人中心>重置密码" }
      },
      {
        path: "/courses/type",
        name: "courseType",
        component: CourseTypeVue,
        meta: { title: "课程管理>课程类型" }
      },
      {
        path: "/courses/manage",
        name: "CourseManage",
        component: CourseManageVue,
        meta: { title: "课程管理>课程库" }
      },
      {
        path: "/courses/comment",
        name: "CommentManage",
        component: CommentManageVue,
        meta: { title: "课程管理>评论库" }
      },
      {
        path: "/user/manage",
        component: UserManageVue,
        name: "UserManage",
        meta: { title: "用户管理" }
      },
      {
        path: "/purchase/manage",
        name: "PurchaseManage",
        component: PurchaseManageVue,
        meta: { title: "订单管理" }
      },
      {
        path: "/homework/manage",
        name: "HomeworkManage",
        component: HomeworkManageVue,
        meta: { title: "作业管理>作业库" }
      },
      {
        path: "/exam/manage",
        name: "ExamManage",
        component: ExamManageVue,
        meta: { title: "考试管理>试卷库" }
      },
      {
        path: "/exam/Usermanage",
        name: "ExamUserManage",
        component: UserEMGradeManageVue,
        meta: { title: "考试管理>学生试卷库" }
      },
      {
        path: "/homework/Usermanage",
        name: "HomeworkUserManage",
        component: UserHKGradeManageVue,
        meta: { title: "作业管理>学生作业库" }
      },
      {
        path: "/setting/loginfo",
        name: "LogInfoManage",
        component: LogInfoManageVue,
        meta: { title: "设置->日志管理" }
      },
      {
        path: "/setting/notice",
        name: "NoticeManage",
        component: NoticeManageVue,
        meta: { title: "设置->公告管理" }
      },
      {
        path: "/homepage",
        name: "HomePage",
        component: HomePageVue,
        meta: { title: "首页" }
      },

      {
        path: '/courses/:courseId/comments',
        name: 'CourseCMTManage',
        component: CourseCMTManageVue,
        meta: { title: "课程评论区" }
      },
      {
        path: '/coze',
        name: 'Coze',
        component: CozeVue,
        meta: { title: "云课堂助手" }
      }

    ],
  },
];

////创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes: routes,
});

//导出路由
export default router;
